package com.javasm.controller.goods;


import com.javasm.common.http.AxiosResult;
import com.javasm.common.page.PageResult;
import com.javasm.controller.base.BaseController;
import com.javasm.domin.criteria.goods.ProductCriteria;
import com.javasm.domin.entity.Category;
import com.javasm.domin.entity.goods.Product;
import com.javasm.domin.vo.goods.ProductVo;
import com.javasm.service.goods.IProductService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author whl
 * @since 2022-01-14
 */
@RestController
@RequestMapping("product")
@RequiredArgsConstructor
public class ProductController extends BaseController {


    private final IProductService iProductService;

    @GetMapping("findProduct")
    public AxiosResult<List<Product>> findProduct(){
        List<Product> list = iProductService.list();
        return AxiosResult.success(list);
    }

    /**
     * 分页条件查询
     */
    @GetMapping("findProducts")
    public AxiosResult<PageResult<ProductVo>> list(ProductCriteria productCriteria) {
        PageResult<ProductVo> list = iProductService.searchPage(productCriteria);
        return AxiosResult.success(list);
    }

}
